﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;

namespace K9Nano.Domain
{
    public interface IReadOnlyRepository<TEntity, in TKey> 
        where TEntity : class, IEntity<TKey>
        where TKey : IEquatable<TKey>
    {
        TEntity Get(TKey id);

        ValueTask<TEntity> GetAsync(TKey id, CancellationToken cancellation = default);

        List<TEntity> GetAllList();

        ValueTask<List<TEntity>> GetAllListAsync(CancellationToken cancellation = default);

        TEntity FirstOrDefault(TKey id);

        ValueTask<TEntity> FirstOrDefaultAsync(TKey id, CancellationToken cancellation = default);

        TEntity FirstOrDefault([NotNull]Expression<Func<TEntity, bool>> predicate);

        ValueTask<TEntity> FirstOrDefaultAsync([NotNull]Expression<Func<TEntity, bool>> predicate, CancellationToken cancellation = default);
    }
}